package com.mall.order.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

/**
 * @author: 谢君臣
 * @Date: 2022/8/5-16:58
 * @version: 1.0
 * @function:
 */
@Configuration
public class ThreadPoolConfig {
    
    private int coreSize;
    private int maxiSize;
    private long keepAliveTime;
    private TimeUnit unit;
    private BlockingQueue<Runnable> workQueue;
    private ThreadFactory threadFactory;
    private RejectedExecutionHandler handler;

    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
      return new ThreadPoolExecutor(20,
                200,
                10,
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(100000),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
    }
}
